package com.amsp.oa.oademo.service.impl;

import com.amsp.oa.oademo.entity.EmployeeReinstatement;
import com.amsp.oa.oademo.mapper.EmployeeReinstatementMapper;
import com.amsp.oa.oademo.service.EmployeeReinstatementService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

@Service
public class EmployeeReinstatementServiceImpl extends ServiceImpl<EmployeeReinstatementMapper, EmployeeReinstatement> implements EmployeeReinstatementService {

    @Override
    public IPage<EmployeeReinstatement> getPage(Integer current, Integer size, String employeeName, String employeeId, String originalDepartment) {
        LambdaQueryWrapper<EmployeeReinstatement> wrapper = new LambdaQueryWrapper<>();
        
        if (StringUtils.isNotBlank(employeeName)) {
            wrapper.like(EmployeeReinstatement::getEmployeeName, employeeName);
        }
        if (StringUtils.isNotBlank(employeeId)) {
            wrapper.like(EmployeeReinstatement::getEmployeeId, employeeId);
        }
        if (StringUtils.isNotBlank(originalDepartment)) {
            wrapper.like(EmployeeReinstatement::getOriginalDepartment, originalDepartment);
        }
        
        wrapper.orderByDesc(EmployeeReinstatement::getCreateTime);
        
        return page(new Page<>(current, size), wrapper);
    }
} 